package edu.cuit.campus.web.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/8/19 14:09
 */
@Slf4j
public class RoleInterceptor3 implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        var method = (HandlerMethod) handler;
        log.debug("RoleInterceptor3的前置方法,拦截到的handler:{}", method.toString());
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        var method = (HandlerMethod) handler;
        log.debug("RoleInterceptor3的后置方法,执行的handler:{}",
                method.toString());
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        var method = (HandlerMethod) handler;
        log.debug("RoleInterceptor3在视图渲染完毕后执行的完成方法,handler:{}", method.toString());
    }
}
